import type { Directive } from "vue";

const Permission: Directive = {
    mounted(el, binding) {
        const { currentRouteMeta, permission } = binding.value
        // console.log(currentRouteMeta, permission);

        if (currentRouteMeta && permission) {
            if (currentRouteMeta.indexOf(permission) < 0) {
                el.remove()
            }
        } else if (!currentRouteMeta) {
            el.remove()
        }
    },
    unmounted(el) {
        el.remove()
    },
}

export default Permission  